<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <script src="../js/axios.min.js" type="text/javascript"></script>
    <script src="../js/vue.js" type="text/javascript"></script>
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <title>我的订单</title>
</head>
<body>
<div id="app">
<el-container>
    <el-main>
        <!--条件查询-->
        <el-form :inline="true" :model="condition" class="demo-form-inline">
            <el-form-item label="查询">
                <el-input v-model="condition" placeholder="关键字"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="search()">查询</el-button>
            </el-form-item>
        </el-form>
        <!--展示我的订单-->
        <el-table :data="order" border>
            <el-table-column prop="no" label="订单号">
            </el-table-column>
            <el-table-column prop="coachName" label="教练">
            </el-table-column>
            <el-table-column prop="createTime" label="创建时间">
            </el-table-column>
            <el-table-column prop="lessonName" label="课程">
            </el-table-column>
            <el-table-column prop="lessonTime" label="上课时间">
            </el-table-column>
            <el-table-column prop="price" label="金额">
            </el-table-column>
            <el-table-column prop="state" label="状态">
            </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button type="text" size="small">付款</el-button>
                </template>
            </el-table-column>
        </el-table>
        <!--分页-->
        <div class="block">
            <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="pageInfo.currentPage"
                    :page-sizes="[3, 4]"
                    :page-size="100"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="pageInfo.total">
            </el-pagination>
        </div>
    </el-main>
</el-container>
</div>
<script>
    new Vue({
        el: "#app",
        data() {
            return {
                pageInfo: {
                    currentPage: 1,// 当前页
                    size: 3,// 每页多少条
                    total: 1// 总条目数
                },
                order: [],
                condition: ""
            }
        },
        methods: {
            // 分页 - 更改每页条数
            handleSizeChange(val) {
                this.pageInfo.size = val
                this.getAll();
            },
            // 分页 - 更改当前页
            handleCurrentChange(val) {
                this.pageInfo.currentPage = val
                this.getAll();
            },
            // 获取所有
            getAll(){
                axios.get("/order/getMyOrder?page="+this.pageInfo.currentPage+"&size="+this.pageInfo.size).then(resp=>{
                    if(resp.status === resp.data.code){
                        this.order = resp.data.data.records
                        this.pageInfo.total = resp.data.data.total
                        console.log(this.order)
                    }
                })
            },
            // 条件查询
            search(){
                axios.get().then(resp=>{
                    if(resp.status === resp.data.code){
                        // TODO
                    }
                })
            }
        },
        created() {
            this.getAll()
        }
    })
</script>
</body>
</html>